/* This file is part of SpaceSim.
 
 SpaceSim is free software: you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation, either version 3 of the License, or
 (at your option) any later version.
 
 SpaceSim is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.
 
 You should have received a copy of the GNU General Public License
 along with SpaceSim.  If not, see <http://www.gnu.org/licenses/>. */

#include "star.h"

#include "graphics.h"
#include "random.h"
#include "player.h"

Star Stars[NUM_STARS];

Star::Star () {
	XPos = Random::Rand(-450.f, 450.f);
	YPos = Random::Rand(-350.f, 350.f);
}

void Star::Draw() {
	// If we went too far from the player, move to the opposite side
	while (XPos < player.GetX() - 450.f) {
		XPos += 900.f;
	}
	while (XPos > player.GetX() + 450.f) {
		XPos -= 900.f;
	}
	while (YPos < player.GetY() - 350.f) {
		YPos += 700.f;
	}
	while (YPos > player.GetY() + 350.f) {
		YPos -= 700.f;
	}
	Graphics::App.Draw(sf::Shape::Circle(XPos * Graphics::ZoomFactor, YPos * Graphics::ZoomFactor, 1.0, sf::Color::White));
}